<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
             <div class="fieldBox">
                <div class="label">产品型号</div>
                <div class="field">
                    <input name="prdMdl" id="prdMdl" type="text"   class="ui-textbox" value="">
                </div>
            </div>
  
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn" class="sq-button sq-button-round" onclick="searchBtn()">查询</span>
              <span id="clearBtn" class="sq-button sq-button-round" onclick="clearBtn()">清空</span>
            </div>
        </div>
    </form>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	var prjId= '${prjId}';
	var prdType = '${prdTypCd}';
	var prdNm = '${prdNm}'; 
	var prdId = '${prdId}';
	
	$(function () {
		//console.log(prdNm);
		prdGrid(prdType);
		  $("#searchBar").ligerForm();
	});
	//根据产品类型加载不同的grid
	function prdGrid(prdType){/* //008001 */
		var audStsCdList = new Array();//审核状态
		audStsCdList.push(CommonConstant.C_AUD_NO_HAPPEN_CODE);
		audStsCdList.push(CommonConstant.C_AUD_ADNWAY_CODE);
		audStsCdList.push(CommonConstant.C_AUD_PASS_CODE);
		var audStsCdListArr = JSON.stringify(audStsCdList);
		if(prdType){
			var type = prdType.substring(0,ProjectConstant.PRD_TYE_LENGHT);//截取前三位字符串
			//type = 乘用车（007） 或者客车（009） 或者卡车类客车（016）
			if(type==ProjectConstant.PRD_CAR_CD||type==ProjectConstant.PRD_BUS_CD||type==ProjectConstant.PRD_TK_BUS_CD){
			    $("#ligergrid1").ligerGrid({
			    
			    	url: '<%=path%>/project/prjbscinfo/initPrdCarList.do?prdTypCd='+prdType+'&&audStsCdList='+audStsCdListArr+'&&prdNm='+prdNm,
			    	method : 'get',
			        columns: [
			            { display: '产品名称', name: 'prdNm', minWidth: 140 , enabledSort:true},
			            { display: '产品型号', name: 'prdMdl', minWidth: 140 , enabledSort:true},
			            { display: '发动机型号', name: 'engMdl', minWidth: 140 , enabledSort:true},
			            { display: '座位数', name: 'seatQtyCd', minWidth: 140 , enabledSort:true},
			            { display: '车身长度', name: 'carLen', minWidth: 140 , enabledSort:true},
			            { display: '产品类型', name: 'prdTypCdNm', minWidth: 140 , enabledSort:true},
			            { display: '品牌', name: 'brCd', width: 50 , enabledSort:true},
			            {
			                display: '操作',
			                isSort: false,
			                width: 100,
			                render: function (rowdata, rowindex, value){
			                //	console.log(rowdata.seatQtyCd);
			                    var h='<a class="sq-button-hasicon" href="javascript:choosePrdRow(';
			                        h+="'"+rowdata.id+"',";
			                        h+="'"+rowdata.prdMdl+"',";//车系
			                        h+="'"+rowdata.engMdl+"',";
			                        h+="'"+rowdata.prdId+"',";
			                        h+="'"+rowdata.carLen+"',";
			                        h+="'"+rowdata.seatQtyCd+"',";
			                        h+="'"+rowdata.prdMdl+"'";//产品型号
			                        h+=')"><i class="sqBtnIco_3"></i>选择</a>'
			                    return h;
			                }
			            }
			        ],
			        pageSize:10,
			        root:'rows',
			        record:'total',
			        hideLoadButton : true,
			        width: '100%',
			        height:'100%',
			        heightDiff:-2,
			        //isScroll: false,
			        checkbox:true,
			        rownumbers:true/* ,
			        onRenderComplete: function () {
			        	iframeResize ();
			        } */
			    });
			}else{
			    $("#ligergrid1").ligerGrid({
			    	url: '<%=path%>/project/prjbscinfo/initPrdTkList.do?prdTypCd='+prdType+'&&audStsCdList='+audStsCdListArr,
			    	method : 'get',
			        columns: [
			            { display: '产品名称', name: 'prdNm', minWidth: 140 , enabledSort:true},
			            { display: '产品型号', name: 'prdMdl', minWidth: 140 , enabledSort:true},
			            { display: '发动机型号', name: 'engMdl', minWidth: 140 , enabledSort:true},
			            { display: '产品类型', name: 'prdTypCdNm', minWidth: 140 , enabledSort:true},
			            { display: '品牌', name: 'brCd', width: 50 , enabledSort:true},
			            {
			                display: '操作',
			                isSort: false,
			                width: 100,
			                render: function (rowdata, rowindex, value){
			                    var h='<a class="sq-button-hasicon" href="javascript:choosePrdRow(';
				                    h+="'"+rowdata.id+"',";
				                    if(rowdata.prdMdl){
				                        h+="'"+rowdata.prdMdl+"',";
					                    }else{
					                    	  h+="' ',";
					                    }
					                    if(rowdata.engMdl){
				                        h+="'"+rowdata.engMdl+"',";
					                    }else{
					                     h+="' ',";
					                    }
					                    if(rowdata.prdId){
					                        h+="'"+rowdata.prdId+"',";
						                }else{
						                     h+="' ',";
						                }
					                    if(rowdata.carLen){
					                    	h+="'"+rowdata.carLen+"',";
					                    }else{
					                    	h+="'',";
					                    }
					                    if(rowdata.seatQtyCd){
					                    	h+="'"+rowdata.seatQtyCd+"',";
					                    }else{
					                    	h+="'',";
					                    }
				                        if(rowdata.prdMdl){
				                        	h+="'"+rowdata.prdMdl+"'";//产品型号
				                        }else{
				                        	h+="' '";
				                        }
			                        h+=')"><i class="sqBtnIco_3"></i>选择</a>'
			                    return h;
			                }
			            }
			        ],
			        pageSize:10,
			        root:'rows',
			        record:'total',
			        hideLoadButton : true,
			        width: '100%',
			        height:'100%',
			        heightDiff:-2,
			        //isScroll: false,
			        checkbox:true,
			        rownumbers:true/* ,
			        onRenderComplete: function () {
			        	iframeResize ();
			        } */
			    });
			}
		}
	    grid = liger.get("ligergrid1");
	}
	//查询
	function searchBtn(){
        var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
           grid.setParm(name,data[name]);
        };
        prdGrid(prdType);
}
//选择  ,查询列表的参数给父页面赋值
	function choosePrdRow(detailId,prdMdl,engMdl,prdId,carLen,seatQtyCd,dtlprdMdl){
		parent.window.document.getElementById("detailId").value=detailId;
		if(!detailId){
			detailId = "";
		}
		if(!prdMdl||prdMdl=='null'){
			prdMdl = "";
		}
		parent.window.document.getElementById("prdMdl").value=prdMdl;//车系
		
		if(!engMdl||engMdl=='null'){
			engMdl = "";
		}
		parent.window.document.getElementById("engMdl").value=engMdl;//发动机型号
		parent.window.document.getElementById("basePrdId").value=prdId;

		parent.window.document.getElementById("prdId").value=prdId;
		if(!carLen||carLen=='null'){
			carLen = "";
		}
		if(parent.window.document.getElementById("carLen")){
			parent.window.document.getElementById("carLen").value=carLen;//车身长度
			}
		
		if(!seatQtyCd||seatQtyCd=='null'){
			seatQtyCd = "";
		} 
		if(parent.window.document.getElementById("seatQtyCd")){
			parent.window.document.getElementById("seatQtyCd").value=seatQtyCd;//座位数
		}
		if(!dtlprdMdl||dtlprdMdl=='null'){
			dtlprdMdl = "";
		}
		if(parent.window.document.getElementById("dtlprdMdl")){
			parent.window.document.getElementById("dtlprdMdl").value=dtlprdMdl;//产品型号
		}
		
		parent.$.ligerDialog.close();
		parent.$(".l-dialog,.l-window-mask").css("display","none"); 
	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}

</script>

</body>
</html>